(function(m,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(m=typeof globalThis<"u"?globalThis:m||self,t(m["seyu-vfx"]={},m.Vue))})(this,function(m,t){"use strict";function w(e,A=500,a=!1){let i=null;function n(...l){if(clearTimeout(i),a){const u=!i;i=setTimeout(()=>{i=null},A),u&&e.apply(this,l)}else i=setTimeout(()=>{e.apply(this,l)},A)}return n}function T(e,A=1e3){let a=null;function i(...n){a===null&&(e.apply(this,n),a=setTimeout(()=>{clearTimeout(a),a=null},A))}return i}function Y(e,A=()=>{},a=()=>{}){const i=new IntersectionObserver(n=>{n[0].intersectionRatio<=0?a==null||a():A==null||A()});return i.observe(e),()=>i.disconnect()}function E(e,A=()=>{}){const a=new ResizeObserver(i=>{A(i[0].target)});return a.observe(e),()=>a.disconnect()}function H(e=!1){const A=Math.floor(Math.random()*256),a=Math.floor(Math.random()*256),i=Math.floor(Math.random()*256),n=Math.floor(Math.random()*10);return`rgba(${A},${a},${i},${e?n:1})`}const W=Object.freeze(Object.defineProperty({__proto__:null,debounce:w,interPage:Y,randomColor:H,resizeListen:E,throttle:T},Symbol.toStringTag,{value:"Module"})),Z={class:"seyu-above"},J=Object.assign({name:"FloatDown",inheritAttrs:!1},{__name:"FloatDown",props:{imgList:{type:Array,default:()=>[""]},minWidth:{type:Number,default:30,validator:e=>e>0},minHeight:{type:Number,default:25,validator:e=>e>0},count:{type:Number,default:10,validator:e=>e>0},xSpeed:{type:Number,default:1,validator:e=>e>0},ySpeed:{type:Number,default:1,validator:e=>e>0},direction:{type:String,default:"left",validator:e=>["left","right"].includes(e)},disableRotate:{type:Boolean,default:!1}},setup(e,{expose:A}){const a=e,i=t.ref(),n=t.ref();let l;function u(){n.value.width=i.value.clientWidth,n.value.height=i.value.clientHeight}const c=t.ref([]);async function h(){await Promise.all(a.imgList.map(s=>new Promise(p=>{const y=new Image;y.src=s,y.onload=()=>{c.value.push(y),p(!0)},y.onerror=()=>{console.error(`图片加载失败: ${s}`),p(!1)}})))}t.watch(()=>a.imgList,h);const o=t.ref([]);function r(){o.value=[];const{minWidth:s,minHeight:p,xSpeed:y,ySpeed:I}=a;for(let R=0;R<a.count;R++){const S=Math.random();o.value.push({x:Math.random()*n.value.width,y:Math.random()*n.value.height*2-n.value.height,xSpeed:Math.random()*y+1,ySpeed:Math.random()*I+1,width:S*(s/2)+s,height:S*(p/2)+p,image:c.value[parseInt(String(Math.random()*c.value.length))],rotate:Math.random()*360,rotateSpeed:Math.random()*4-2})}}function g(){l.clearRect(0,0,n.value.width,n.value.height),o.value.forEach(s=>{const p=Math.sqrt(s.width*s.width+s.height*s.height);s.x>n.value.width+p&&a.direction==="right"||s.x<-p&&a.direction==="left"?(s.x=a.direction==="right"?-s.width:n.value.width+p,s.image=c.value[parseInt(String(Math.random()*c.value.length))]):s.y>n.value.height+p&&(s.y=-p,s.image=c.value[parseInt(String(Math.random()*c.value.length))]),a.disableRotate?l.drawImage(s.image,s.x,s.y,s.width,s.height):(l.save(),l.translate(s.x,s.y),l.rotate(s.rotate*Math.PI/180),l.drawImage(s.image,-s.width/2,-s.height/2,s.width,s.height),l.restore())})}const d=t.ref(!0);t.watch(d,()=>{d.value&&f()});const B=t.ref(!0);function f(){o.value.forEach(s=>{s.x+=a.direction==="left"?-s.xSpeed:s.xSpeed,s.y+=s.ySpeed,s.rotate+=s.rotateSpeed}),n.value&&g(),d.value&&B.value&&requestAnimationFrame(f)}return t.onMounted(async()=>{await h(),E(i.value,w(u)),Y(i.value,()=>{B.value=!0,d.value&&f(),u(),r()},()=>{B.value=!1}),l=n.value.getContext("2d")}),A({start:(s=!0)=>{s&&r(),d.value=!0},stop:(s=!0)=>{d.value=!1,s&&requestAnimationFrame(()=>{l.clearRect(0,0,n.value.width,n.value.height)})}}),(s,p)=>(t.openBlock(),t.createElementBlock("div",{class:"seyu-shell",ref_key:"floatDown",ref:i},[t.renderSlot(s.$slots,"default"),t.createElementVNode("canvas",{ref_key:"canvas",ref:n,class:"seyu-canvas"},null,512),t.createElementVNode("div",Z,[t.renderSlot(s.$slots,"above")])],512))}}),j=["零","一","二","三","四","五","六","七","八","九","十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十","三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十","四十一","四十二","四十三","四十四","四十五","四十六","四十七","四十八","四十九","五十","五十一","五十二","五十三","五十四","五十五","五十六","五十七","五十八","五十九","六十"];function G(e){return e?["星期天","星期一","星期二","星期三","星期四","星期五","星期六"]:["周日","周一","周二","周三","周四","周五","周六"]}function N(e,A,a,i=1){const n=[];for(let l=0;l<e;l++)n.push(`${A?j[l+i]:l+i}${a}`);return n}const F={Month:()=>({labelList:N(12,!0,"月"),length:12,textLength:3,prop:"month"}),month:()=>({labelList:N(12,!1,"月"),length:12,textLength:2.5,prop:"month"}),Day:()=>({labelList:N(31,!0,"日"),length:31,textLength:4,prop:"day"}),day:()=>({labelList:N(31,!1,"日"),length:31,textLength:2.5,prop:"day"}),Week:()=>({labelList:G(!0),length:7,textLength:3,prop:"week"}),week:()=>({labelList:G(!1),length:7,textLength:2,prop:"week"}),Hour:()=>({labelList:N(24,!0,"时",0),length:24,textLength:4,prop:"hour"}),hour:()=>({labelList:N(24,!1,"点",0),length:24,textLength:2.5,prop:"hour"}),Minute:()=>({labelList:N(60,!0,"分",0),length:60,textLength:4,prop:"minute"}),minute:()=>({labelList:N(60,!1,"分",0),length:60,textLength:2.5,prop:"minute"}),Seconds:()=>({labelList:N(60,!0,"秒",0),length:60,textLength:4,prop:"seconds"}),seconds:()=>({labelList:N(60,!1,"秒",0),length:60,textLength:2.5,prop:"seconds"})};function X({format:e,gap:A,fontSize:a}){const i=[];let n=0;return e.reverse().forEach((l,u)=>{const c=u*A,h=F[l];if(h){const o=h();i.push({...o,dWidth:(n+c)*2}),n+=o.textLength*a}}),i.reverse()}function z(e){return e||e===0?String(e).split("").map(a=>j[Number(a)]).join(""):""}const se="",v={class:"seyu-shell"},Q=Object.assign({name:"CompassClock",inheritAttrs:!1},{__name:"CompassClock",props:{format:{type:Array,default:()=>["Year","Month","Day","Week","Hour","Minute","Seconds"]},gap:{type:Number,default:10},fontSize:{type:Number,default:14},color:{type:String,default:"#000000"},highlightColor:{type:String,default:"#09c"}},setup(e,{expose:A}){t.useCssVars(o=>({"7cd69d12":n.value}));const a=e,i=t.computed(()=>X(a)),n=t.computed(()=>`${a.fontSize}px`),l=t.reactive({}),u=t.computed(()=>{const o=a.format||[];return o.includes("Year")?`${z(l.year)}年`:o.includes("year")?`${l.year}年`:""});let c;function h(){const o=new Date;l.month=o.getMonth(),l.day=o.getDate()-1,l.week=o.getDay(),l.hour=o.getHours(),l.minute=o.getMinutes(),l.seconds=o.getSeconds(),l.year=o.getFullYear(),c=setTimeout(h,100)}return h(),A({start:()=>{clearTimeout(c),h()},stop:()=>{clearTimeout(c)}}),(o,r)=>(t.openBlock(),t.createElementBlock("div",v,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value,(g,d)=>(t.openBlock(),t.createElementBlock("div",{class:"seyu-time-text",key:d,style:t.normalizeStyle({width:`calc(100% - ${g.dWidth}px)`,height:`calc(100% - ${g.dWidth}px)`})},[t.createElementVNode("div",{class:"seyu-time-rotate",style:t.normalizeStyle({transform:`rotate(-${360/g.length*l[g.prop]}deg)`})},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(g.labelList,(B,f)=>(t.openBlock(),t.createElementBlock("div",{key:f,style:t.normalizeStyle({transform:`translateY(-50%) rotate(${360/g.length*f}deg)`,color:f===l[g.prop]?a.highlightColor:a.color})},t.toDisplayString(B),5))),128))],4)],4))),128)),t.createElementVNode("div",{class:"seyu-time-year",style:t.normalizeStyle({color:a.highlightColor})},t.toDisplayString(u.value),5)]))}});function V(e,A){const a=t.computed(()=>{var r;return((r=e==null?void 0:e.value)==null?void 0:r.clientWidth)||100}),i=t.computed(()=>{var r;return((r=e==null?void 0:e.value)==null?void 0:r.clientHeight)||100}),n=t.ref(0);function l(){return A==="random"?H():Array.isArray(A)?A[Math.floor(Math.random()*(A==null?void 0:A.length))]:"#000000"}function u(r){return{...r,y:Math.random()*(i.value*.7),x:Math.random()*a.value,resetDistance:i.value/3}}function c(r=""){return r.split("").map(d=>({text:d,x:Math.random()*a.value,y:Math.random()*-120,h:n.value,color:l(),resetDistance:i.value/3}))}function h(r=""){return[{text:r,x:Math.random()*a.value,y:Math.random()*-120,h:n.value,color:l(),resetDistance:i.value/3}]}function o(r,g,d){switch(n.value=d,g){case"split":return c(r);case"level":return h(r)}}return{getDrawItemList:o,getReset:u}}function P(e,A){const a=t.computed(()=>{var c;return(c=e==null?void 0:e.value)==null?void 0:c.getContext("2d")}),i=t.ref("color"),n=new Image;n.onload=function(){var c,h;i.value="img",a.value.drawImage(n,0,0,(c=e.value)==null?void 0:c.width,(h=e.value)==null?void 0:h.height)};function l(){var c,h;a.value.fillStyle=A.bgColor,a.value.fillRect(0,0,(c=e.value)==null?void 0:c.width,(h=e.value)==null?void 0:h.height),i.value="color",A.bgImg.trim()&&(n.src=A.bgImg)}function u(){var o,r;const[c=0,h=0]=[(o=e.value)==null?void 0:o.width,(r=e.value)==null?void 0:r.height];if(a.value.globalAlpha=.2,i.value==="img"){a.value.drawImage(n,0,0,c,h),a.value.globalAlpha=1;return}a.value.fillStyle=A.bgColor,a.value.fillRect(0,0,c,h),a.value.globalAlpha=1}return{setBg:l,overlay:u}}const q={class:"seyu-above"},b=Object.assign({name:"CodeRain",inheritAttrs:!1},{__name:"CodeRain",props:{bgImg:{type:String,default:""},bgColor:{type:String,default:"#000000"},textMsg:{type:String,default:"rain"},mode:{type:String,validator:e=>["split","level"].includes(e),default:"split"},textColor:{type:[String,Array],validator:e=>Array.isArray(e)||e==="random",default:"random"},fontSize:{type:String,default:"16px"},speed:{type:Number,default:1,validator:e=>e>0}},setup(e,{expose:A}){const a=e,i=t.ref(),n=t.ref(),l=t.ref(0),{setBg:u,overlay:c}=P(n,a);function h(){var I,R,S;n.value&&(n.value.width=((I=i.value)==null?void 0:I.clientWidth)||0,n.value.height=((R=i.value)==null?void 0:R.clientHeight)||0,l.value=((S=i.value)==null?void 0:S.clientHeight)||0,B(),u(),p())}let o;const r=t.reactive([]),{getDrawItemList:g,getReset:d}=V(i,a.textColor);function B(){const{fontSize:I,textMsg:R,mode:S}=a;o.font=`${I} 楷体`;const x=o.measureText(R);let M=x.width;const k=x.actualBoundingBoxAscent+x.actualBoundingBoxDescent,O=i.value.clientWidth/M;r.splice(0,r.length);for(let D=0;D<O;D++)r.push(g(R,S,k))}function f(){c(),o.globalAlpha=1,r.forEach((I,R)=>{I==null||I.forEach((S,x)=>{const{color:M,text:k,x:O,y:D,h:K,resetDistance:C}=S;o.fillStyle=M,o.fillText(k,O,D);const le=D>l.value||Math.random()>.8&&C<0;r[R][x]=le?d(S):{...S,y:D+K,resetDistance:C-K}})})}let s;function p(){clearInterval(s),s=setInterval(f,a.speed*17)}function y(){clearInterval(s)}return t.onMounted(()=>{E(i.value,w(h)),o=n.value.getContext("2d")}),A({start:p,stop:y}),(I,R)=>(t.openBlock(),t.createElementBlock("div",{class:"seyu-shell",ref_key:"codeRain",ref:i},[t.createElementVNode("canvas",{ref_key:"canvas",ref:n,class:"seyu-canvas"},null,512),t.createElementVNode("div",q,[t.renderSlot(I.$slots,"default")])],512))}});function _(e,A){const a=t.ref(),i=t.ref(0);function n(u=0){var B;const{duration:c,direction:h,tilt:o}=e,r=h==="left"?-1:1,g=360/c*(c-u)*r+i.value,d=360*r+g;i.value=g,a.value=(B=A.value)==null?void 0:B.animate([{transform:`rotateX(${o}deg) rotateY(${g}deg)`},{transform:`rotateX(${o}deg) rotateY(${d}deg)`}],{duration:c,iterations:1/0})}t.watch(()=>e.direction,()=>{var u;n((u=a.value)==null?void 0:u.currentTime)}),t.onMounted(()=>{n()});function l(){i.value=0,n()}return{animates:a,restAnimates:l}}const Ae="",$={class:"seyu-shell"},L=Object.assign({name:"RotateCards",inheritAttrs:!1},{__name:"RotateCards",props:{data:{type:Array,required:!0},direction:{type:String,validator:e=>["left","right"].includes(e),default:"left"},duration:{type:Number,validator:e=>e>0,default:1e4},radius:{type:[String,Number],default:"40%"},tilt:{type:Number,default:-10},itemClass:{type:String,default:""}},setup(e,{expose:A}){const a=e,i=t.ref(),n=t.ref(0),l=t.computed(()=>{const{radius:o}=a;if(typeof o=="number")return`${o}px`;if(/^\d+px$/.test(o))return o;if(!/^\d+%$/.test(o))return"0px";const r=(Number(o.split("%")[0])||0)/100;return(n.value*r||0).toFixed(2)+"px"}),u=t.computed(()=>360/a.data.length),{animates:c,restAnimates:h}=_(a,i);return t.onMounted(()=>{E(i.value,w(()=>{var o;n.value=(o=i.value)==null?void 0:o.clientWidth}))}),A({rest:h,start:()=>{var o;(o=c.value)==null||o.play()},stop:()=>{var o;(o=c.value)==null||o.pause()}}),(o,r)=>(t.openBlock(),t.createElementBlock("div",$,[t.createElementVNode("div",{class:"seyu-rotate-container",ref_key:"containerRef",ref:i},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data,(g,d)=>(t.openBlock(),t.createElementBlock("div",{key:d,class:t.normalizeClass(["seyu-rotate-item",a.itemClass]),style:t.normalizeStyle({transform:`translate(-50%, -50%) rotateY(${u.value*d}deg) translateZ(${l.value})`})},[t.renderSlot(o.$slots,"default",{item:g})],6))),128))],512)]))}});function ee(e,A){const a=t.computed(()=>{var o;return(o=e==null?void 0:e.value)==null?void 0:o.getContext("2d")}),i=t.reactive([]);class n{constructor(r){const{x:g,y:d,color:B,radius:f,cross:s,vertical:p,topple:y,alpha:I,decay:R,customDraw:S}=r;this.x=g,this.y=d,this.color=B,this.radius=f||1,this.cross=s===0?0:s||Math.random()*2-1,this.vertical=p===0?0:p||Math.random()*2-1,this.topple=y===0?0:y||.01,this.alpha=I||1,this.decay=R||.01,this.customDraw=S}draw(){var r;if(a.value.save(),a.value.globalAlpha=this.alpha,this.customDraw){(r=this.customDraw)==null||r.call(this,{x:this.x,y:this.y,color:this.color},a.value),a.value.restore();return}a.value.beginPath(),a.value.arc(this.x,this.y,this.radius,0,Math.PI*2),a.value.fillStyle=this.color,a.value.fill(),a.value.restore()}update(r){this.x+=this.cross,this.y-=this.vertical,this.vertical-=this.topple,this.alpha-=this.decay,this.alpha<=0&&(r==null||r())}}function l(o=[]){o.forEach(r=>{i.push(new n(r))})}class u{constructor(r){const{x:g,y:d,end:B,radius:f,color:s,speed:p,callback:y}=r;this.x=g,this.y=d,this.end=B,this.radius=f,this.color=s,this.speed=p,this.callback=y}draw(){var g;const r=((g=e==null?void 0:e.value)==null?void 0:g.height)||0;a.value.beginPath(),a.value.arc(this.x,r-this.y,this.radius,0,Math.PI*2),a.value.fillStyle=this.color,a.value.fill()}update(r){var g;this.y+=this.speed,this.y>=this.end&&(r==null||r(),this.callback({x:this.x,y:((g=e==null?void 0:e.value)==null?void 0:g.height)-this.y}))}}function c(o){i.push(new u(o))}function h(){A==null||A(),i.forEach((o,r)=>{o.draw(),o.update(()=>i.splice(r,1))}),requestAnimationFrame(h)}return t.onMounted(()=>{h()}),{canvasContext:a,fire:c,createShards:l}}const te=["irregularity","circle"];function ae(e){function A(){const{diffuseColor:l}=e;if(Array.isArray(l)){const u=Math.floor(Math.random()*l.length);return l[u]}return H()}function a(l,u){const{diffuseRadius:c}=e,h=[];for(let o=0;o<30;o++)h.push({x:l,y:u,color:A(),radius:c});return h}function i(l,u){const c=[],o=Math.PI*2/36;for(let r=0;r<36;r++)c.push({x:l,y:u,color:A(),radius:e.diffuseRadius,cross:Math.cos(o*r),vertical:Math.sin(o*r),topple:0});return c}function n(l={},u=te){const c=Math.floor(Math.random()*u.length),h=u[c],{x:o,y:r}=l;switch(h){case"irregularity":return a(o,r);case"circle":return i(o,r);default:return a(o,r)}}return{getShape:n}}function oe(e,{fire:A,createShards:a,getShape:i},n){const l=t.ref(0);function u(){const{riseColor:o}=e;if(Array.isArray(o)){const r=Math.floor(Math.random()*o.length);return o[r]}return H()}function c(){const{height:o,width:r}=(n==null?void 0:n.value)||{};if(!(o>0))return;const g=o/2,{shape:d,riseSpeed:B,riseRadius:f}=e;l.value++,A({x:r*Math.random(),y:0,end:g*Math.random()+g,radius:f,color:u(),speed:B,callback:s=>{const p=i(s,d);a(p),l.value--,e.autoFire&&c()}})}function h(){if(!e.autoFire)return;const o=e.riseCount-l.value;for(let r=0;r<o;r++)setTimeout(c,200)}return t.watch(()=>e.autoFire,()=>{h()}),{initAuto:h}}const re={class:"seyu-above"},U=Object.assign({name:"FireWorks",inheritAttrs:!1},{__name:"FireWorks",props:{bgImg:{type:String,default:""},bgColor:{type:String,default:"#000000"},riseRadius:{type:Number,default:2,validator:e=>e>0},riseColor:{type:[String,Array],validator:e=>Array.isArray(e)||e==="random",default:"random"},riseSpeed:{type:Number,default:2,validator:e=>e>0},riseCount:{type:Number,default:5,validator:e=>e>0},diffuseRadius:{type:Number,default:2,validator:e=>e>0},diffuseColor:{type:[String,Array],validator:e=>Array.isArray(e)||e==="random",default:"random"},autoFire:{type:Boolean,default:!0},shape:{type:Array}},setup(e,{expose:A}){const a=e,i=t.ref(),n=t.ref(),{setBg:l,overlay:u}=P(n,a),{fire:c,createShards:h}=ee(n,u),{getShape:o}=ae(a),{initAuto:r}=oe(a,{fire:c,createShards:h,getShape:o},n);function g(){var d,B;n.value&&(n.value.width=((d=i.value)==null?void 0:d.clientWidth)||0,n.value.height=((B=i.value)==null?void 0:B.clientHeight)||0,l(),r())}return t.onMounted(()=>{E(i.value,w(g))}),A({fire:c,createShards:h,getShape:o}),(d,B)=>(t.openBlock(),t.createElementBlock("div",{class:"seyu-shell",ref_key:"fireWorks",ref:i},[t.createElementVNode("canvas",{ref_key:"canvas",ref:n,class:"seyu-canvas"},null,512),t.createElementVNode("div",re,[t.renderSlot(d.$slots,"default")])],512))}}),ce="",ne=[J,Q,b,L,U],ie={install(e){ne.forEach(A=>{e.component(A.name,A)})}};m.CodeRain=b,m.CompassClock=Q,m.FireWorks=U,m.FloatDown=J,m.RotateCards=L,m.default=ie,m.utils=W,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
